;; Tests for the nested-vector implementation

;; by Konrad Hinsen
;; last updated February 8, 2010

;; Copyright (c) Konrad Hinsen, 2009-2010. All rights reserved.  The use
;; and distribution terms for this software are covered by the Eclipse
;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this
;; distribution.  By using this software in any fashion, you are
;; agreeing to be bound by the terms of this license.  You must not
;; remove this notice, or any other, from this software.

(ns multiarray-tests-colt
  (:use [multiarray.protocol]
	[clojure.test :only (deftest is are run-tests)])
  (:require [multiarray.colt :as implementation]))

(deftest creation-test
  (is (thrown? Exception (implementation/zeros [])))
  (is (thrown? Exception (implementation/zeros [1 2 1 2]))))

(deftest shape-test-zeros
  (doseq [s [ [2] [3 2] [4 1 2] ]]
    (is (= (shape (implementation/zeros s)) s))))

(deftest rank-test-zeros
  (are [x y] (= x y)
       (rank (implementation/zeros [2]))     1
       (rank (implementation/zeros [3 2]))   2
       (rank (implementation/zeros [3 1 2])) 3))

(deftest type-test
  (doseq [el-class [ Integer/TYPE Float/TYPE Double/TYPE Object ]]
    (is (= (element-class (implementation/zeros [3] el-class)) el-class)))
  (doseq [el-class [ Boolean/TYPE Byte/TYPE Short/TYPE ]]
    (is (= (element-class (implementation/zeros [3] el-class)) Integer/TYPE))))

(run-tests)

